import request from '@/utils/request'

interface ApiResponse<T = any> {
  code: number;
  msg: string;
  data: T;
}

interface SysServer {
  id?: number;
  name: string;
  ipAddress: string;
  os: string;
  port: number;
  username: string;
  password?: string;
  description?: string;
  status: number;
}

export function getServerList(params?: any): Promise<ApiResponse<any>> {
  return request({
    url: '/api/server/list',
    method: 'get',
    params
  })
}

export function getServerPage(params?: any): Promise<ApiResponse<any>> {
  return request({
    url: '/api/server/page',
    method: 'get',
    params
  })
}

export function addServer(data: SysServer): Promise<ApiResponse<any>> {
  return request({
    url: '/api/server',
    method: 'post',
    data
  })
}

export function updateServer(data: SysServer): Promise<ApiResponse<any>> {
  return request({
    url: '/api/server',
    method: 'put',
    data
  })
}

export function deleteServer(id: number): Promise<ApiResponse<any>> {
  return request({
    url: `/api/server/${id}`,
    method: 'delete'
  })
} 